package com.gg.registration.model.hosp;

import com.alibaba.fastjson.JSONObject;
import com.gg.registration.model.base.BaseMongoEntity;
import lombok.Data;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Objects;

/**
 * <p>
 * Hospital
 * </p>
 *
 * @author qy
 */
@Data
@Document("Hospital")
public class Hospital extends BaseMongoEntity {
	
	private static final long serialVersionUID = 1L;
	
	@Indexed(unique = true) //唯一索引
	private String hoscode;

	@Indexed //普通索引
	private String hosname;

	private String hostype;

	private String provinceCode;

	private String cityCode;

	private String districtCode;

	private String address;

	private String logoData;

	private String intro;

	private String route;

	private Integer status;

	@Transient//不会被加入数据库
	private String timestamp;

	@Transient
	private String sign;

	//预约规则
	private BookingRule bookingRule;

	public void setBookingRule(String bookingRule) {
		this.bookingRule = JSONObject.parseObject(bookingRule, BookingRule.class);
	}

	public Hospital() {
	}

	@Override
	public String toString() {
		return "Hospital{" +
				"hoscode='" + hoscode + '\'' +
				", hosname='" + hosname + '\'' +
				", hostype='" + hostype + '\'' +
				", provinceCode='" + provinceCode + '\'' +
				", cityCode='" + cityCode + '\'' +
				", districtCode='" + districtCode + '\'' +
				", address='" + address + '\'' +
				", logoData='" + logoData + '\'' +
				", intro='" + intro + '\'' +
				", route='" + route + '\'' +
				", status=" + status +
				", bookingRule=" + bookingRule +
				'}';
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		Hospital hospital = (Hospital) o;
		return Objects.equals(hoscode, hospital.hoscode) &&
				Objects.equals(hosname, hospital.hosname) &&
				Objects.equals(hostype, hospital.hostype) &&
				Objects.equals(provinceCode, hospital.provinceCode) &&
				Objects.equals(cityCode, hospital.cityCode) &&
				Objects.equals(districtCode, hospital.districtCode) &&
				Objects.equals(address, hospital.address) &&
				Objects.equals(logoData, hospital.logoData) &&
				Objects.equals(intro, hospital.intro) &&
				Objects.equals(route, hospital.route) &&
				Objects.equals(status, hospital.status) &&
				Objects.equals(bookingRule, hospital.bookingRule);
	}

	@Override
	public int hashCode() {
		return Objects.hash(hoscode, hosname, hostype, provinceCode, cityCode, districtCode, address, logoData, intro, route, status, bookingRule);
	}


	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

	public String getHoscode() {
		return hoscode;
	}

	public void setHoscode(String hoscode) {
		this.hoscode = hoscode;
	}

	public String getHosname() {
		return hosname;
	}

	public void setHosname(String hosname) {
		this.hosname = hosname;
	}

	public String getHostype() {
		return hostype;
	}

	public void setHostype(String hostype) {
		this.hostype = hostype;
	}

	public String getProvinceCode() {
		return provinceCode;
	}

	public void setProvinceCode(String provinceCode) {
		this.provinceCode = provinceCode;
	}

	public String getCityCode() {
		return cityCode;
	}

	public void setCityCode(String cityCode) {
		this.cityCode = cityCode;
	}

	public String getDistrictCode() {
		return districtCode;
	}

	public void setDistrictCode(String districtCode) {
		this.districtCode = districtCode;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getLogoData() {
		return logoData;
	}

	public void setLogoData(String logoData) {
		this.logoData = logoData;
	}

	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}

	public String getRoute() {
		return route;
	}

	public void setRoute(String route) {
		this.route = route;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public BookingRule getBookingRule() {
		return bookingRule;
	}

	public void setBookingRule(BookingRule bookingRule) {
		this.bookingRule = bookingRule;
	}
}

